
#include<math.h>
#define N 1000
double g(double x) {

}
double h(double x) {
    return x*x;
}
double k(double x) {
    return x*x+cos(sin(x));
}
double integrate(double(*f)(double),double a,double b) {
    double dx=(b-a)/N,tot=0;
    int i;
    for(i=0; i<N; i++) {
        double top=f(a+dx*i);
        double bottom=f(a+dx*(i+1));
        double h=dx;
        tot+=(top+bottom)*h/2;
    }
    return tot;
}

int main() {
    printf("%f\n",integrate(sin,0,1));
    printf("%f\n",integrate(g,0,1));
    printf("%f\n",integrate(h,0,1));
    printf("%f\n",integrate(k,0,1));
    return 0;
}
